<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        // 备选字符集
        // 定义：规定某一位字符的备选字符列表
        var str ="上海，上天，上哪里去";
        var reg =/上[海天]/g
        console.log(str.replace(reg,"*"));  // *，*，上哪里去

        var reg = /[上天哪]/g
        var str = "上海，上天，上哪里"
        console.log(str.replace(reg,"*"));  // *海，**，**里

        var str = "我去，我草，你这游戏打的太牛逼了"
        var reg = /[去草]|牛逼/g
        console.log(str.replace(reg,"*"));  // 我*，我*，你这游戏打的太*了

        var res = "ajkdgkbcj128973489"
        var reg = /[0-9]/g
        console.log(res.replace(reg,"*")); // ajkdgkbcj*********

        var str = "hello"
        var reg = /[el]o/g
        console.log(str.replace(reg,"*")); // hel*
    </script>
</body>
</html>